﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Model.Entities_EF
{
    public partial class ICPrkmonitorContext : DbContext
    {
        private readonly RSServerSettingsModel _rsServerSettingsModel;
        public ICPrkmonitorContext(RSServerSettingsModel rsServerSettingsModel)
        {
            _rsServerSettingsModel = rsServerSettingsModel;
        }

        public ICPrkmonitorContext(DbContextOptions<ICPrkmonitorContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Tbhistory> Tbhistory { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                optionsBuilder.UseSqlServer(_rsServerSettingsModel.SqlConnectionString);
            }
        }

        //protected override void OnModelCreating(ModelBuilder modelBuilder)
        //{
        //    modelBuilder.Entity<Tbhistory>(entity =>
        //    {
        //        entity.ToTable("tbhistory");

        //        entity.Property(e => e.Id)
        //            .HasColumnName("ID")
        //            .HasMaxLength(32)
        //            .IsUnicode(false);

        //        entity.Property(e => e.DeviceName)
        //            .HasMaxLength(255)
        //            .IsUnicode(false);

        //        entity.Property(e => e.RecordTime).HasColumnType("datetime");
        //    });

        //    OnModelCreatingPartial(modelBuilder);
        //}

        //partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
